<?php
namespace App\Http\Controllers\Api;

use App\Models\Game;
use App\Http\Resources\Api\Games as GameCollection;

class GamesController extends Controller
{
    public function index()
    {
        $userId = app('auth')->id();

        $result = Game::leftJoin('game_users', 'game_users.id', '=', 'games.id')
            ->where('game_users.user_id', $userId)
            ->paginate(per_page());

        return new GameCollection($result);
    }
}
